'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {};
//条码主档
modelField.BarcodeMaster = {
    type: Schema.ObjectId,
    ref: 'BarcodeMaster',
    Name: '条码主档'
};
//装配条码
modelField.AssemblyBarcode = {
    type: Schema.ObjectId,
    ref: 'BarcodeMaster',
    Name: '装配条码'
};

//类型 0: 装配 1: 容器 2: 芯片更换
modelField.AssemblyType = {
    type: Number,
    Name: '装配类型'
};

//采集时间
modelField.CollectDateTime = {
    type: Date,
    default: Date.now,
    Name: '采集时间'
};

var newModel = new Model(modelField);
newModel.addIndex({BarcodeMaster: 1, AssemblyBarcode: 1}, {"unique": true});
newModel.addIndex({AssemblyBarcode: 1, AssemblyType: 1});
newModel.addIndex({BarcodeMaster: 1, AssemblyType: 1});
newModel.create('AssemblyRelation', '条码装配关系');
